Details of this dataset

Gambia_Indie-MH, sequenced between 2023_03 & 2023_04

Import data

Sample size, loci BEFORE cleanup

Explore data structure

## [1] "Sample size = 346"
## [1] "Loci = 244"
## [1] "1 to 130 alleles per locus per sample"

Merging data (TBD)

Combine multiple sequencing runs

Combine read coverage with parasite density

Adding plate map

Track input reads to amplicon

Looks at dimers

grey = input, colored = amplicons

## [1] "Overall % dimers (already multiplied x100)"
## [1] 0.5306955

Negative controls

Do neg ctrls have a lot of reads?

If so, how will you filter them?

## [1] "Max number of reads in a locus"
## [1] 344
## [1] "List of loci with >100 reads (summed over all negative controls)"
## # A tibble: 25 × 5
##    locus                         reads pool  Gene          Reason_to_include
##    <chr>                         <int> <chr> <chr>         <chr>            
##  1 Pf3D7_13_v3-2814583-2814832-2   344 2     EBL-1         HRP3 deletion    
##  2 Pf3D7_11_v3-1902041-1902278-2   290 2     MAEBL         ch11             
##  3 Pf3D7_13_v3-1726174-1726408-2   269 2     k13           <NA>             
##  4 Pf3D7_12_v3-2092654-2092884-2   249 2     coronin       100              
##  5 Pf3D7_13_v3-1725124-1725365-2   195 2     k13           613              
##  6 Pf3D7_13_v3-1725887-1726123-2   176 2     k13           <NA>             
##  7 Pf3D7_13_v3-2770591-2770863-2   170 2     PF3D7_1369500 HRP3 deletion    
##  8 Pf3D7_11_v3-1950431-1950680-2   169 2     Pf332         ch11             
##  9 Pf3D7_14_v3-294503-294768-2     160 2     pm2           cnv              
## 10 Pf3D7_03_v3-221295-221532-2     159 2     csp           C-terminal       
## # ℹ 15 more rows

Positive controls

Using a known parasite strain at a known density

Alleles should be known

Should be monoclonal (across all loci?)

## [1] "Mean of total locus = 214, Mean prop. of monoclonal loci = 0.85, Mean prop. of polyclonal loci = 0.15"

Clonality of samples

Look at ratio of monoclonals/polyclonals

## [1] "Mean of total locus = 187.52, Mean prop. of monoclonal loci = 0.93, Mean prop. of polyclonal loci = 0.07"

Look at total amplification

All pools

## 
##  1A 1AB  1B 1B2   2 
## 165   5  75   2  29

Species check

Should be Pfal, and not other species

These loci will be filtered out downstream

Identify indels in loci

Look at length of ASVs

##  [1] "Pf3D7_01_v3-162867-163115-1A"    "Pf3D7_01_v3-194742-194973-1B"   
##  [3] "Pf3D7_01_v3-455794-456054-1A"    "Pf3D7_01_v3-535965-536239-1A"   
##  [5] "Pf3D7_02_v3-291770-292017-1A"    "Pf3D7_02_v3-320652-320949-2"    
##  [7] "Pf3D7_02_v3-628941-629172-1A"    "Pf3D7_03_v3-221295-221532-2"    
##  [9] "Pf3D7_03_v3-221463-221712-1B"    "Pf3D7_03_v3-240957-241256-2"    
## [11] "Pf3D7_03_v3-891553-891827-1A"    "Pf3D7_04_v3-1083299-1083563-2"  
## [13] "Pf3D7_04_v3-1113397-1113639-1A"  "Pf3D7_04_v3-141741-141990-1A"   
## [15] "Pf3D7_04_v3-648065-648332-1A"    "Pf3D7_05_v3-1322099-1322341-1A" 
## [17] "Pf3D7_05_v3-369676-369949-1A"    "Pf3D7_05_v3-615379-615678-2"    
## [19] "Pf3D7_05_v3-641131-641404-1A"    "Pf3D7_06_v3-1115900-1116168-1A" 
## [21] "Pf3D7_06_v3-1128558-1128797-1A"  "Pf3D7_06_v3-1135605-1135855-1A" 
## [23] "Pf3D7_06_v3-1136091-1136364-1A"  "Pf3D7_06_v3-1197245-1197515-1A" 
## [25] "Pf3D7_06_v3-1282656-1282930-1A"  "Pf3D7_06_v3-176108-176338-1A"   
## [27] "Pf3D7_06_v3-416462-416720-1A"    "Pf3D7_06_v3-532166-532407-1A"   
## [29] "Pf3D7_07_v3-1028330-1028603-1A"  "Pf3D7_07_v3-105172-105442-1A"   
## [31] "Pf3D7_07_v3-1066661-1066903-1A"  "Pf3D7_07_v3-403801-404052-1B"   
## [33] "Pf3D7_07_v3-404325-404590-1B"    "Pf3D7_07_v3-405517-405773-2"    
## [35] "Pf3D7_07_v3-405570-405844-1B"    "Pf3D7_07_v3-717260-717493-1A"   
## [37] "Pf3D7_08_v3-1313088-1313338-1A"  "Pf3D7_08_v3-1314717-1314986-1A" 
## [39] "Pf3D7_08_v3-1366575-1366822-2"   "Pf3D7_08_v3-1370603-1370853-1B" 
## [41] "Pf3D7_08_v3-1375025-1375284-1B"  "Pf3D7_08_v3-1375205-1375450-2"  
## [43] "Pf3D7_08_v3-1386786-1387035-2"   "Pf3D7_08_v3-412801-413062-1A"   
## [45] "Pf3D7_08_v3-476232-476475-1A"    "Pf3D7_08_v3-550057-550318-2"    
## [47] "Pf3D7_08_v3-585703-585949-1A"    "Pf3D7_08_v3-585993-586266-1A"   
## [49] "Pf3D7_09_v3-1015103-1015350-1A"  "Pf3D7_09_v3-164045-164311-1A"   
## [51] "Pf3D7_09_v3-270915-271160-1A"    "Pf3D7_10_v3-992331-992603-1A"   
## [53] "Pf3D7_10_v3-992596-992869-1A"    "Pf3D7_11_v3-1006693-1006917-1A" 
## [55] "Pf3D7_11_v3-1018781-1019053-1A"  "Pf3D7_11_v3-1294284-1294580-1B" 
## [57] "Pf3D7_11_v3-1950431-1950680-2"   "Pf3D7_11_v3-2001725-2001999-2"  
## [59] "Pf3D7_11_v3-408285-408534-1A"    "Pf3D7_11_v3-497277-497548-1A"   
## [61] "Pf3D7_12_v3-529495-529767-1A"    "Pf3D7_12_v3-659881-660127-1A"   
## [63] "Pf3D7_12_v3-857050-857323-1A"    "Pf3D7_13_v3-1004740-1005002-1A" 
## [65] "Pf3D7_13_v3-1041593-1041860-1AB" "Pf3D7_13_v3-1406713-1406975-1A" 
## [67] "Pf3D7_13_v3-1465010-1465307-1B"  "Pf3D7_13_v3-1465616-1465890-1A" 
## [69] "Pf3D7_13_v3-156456-156685-1A"    "Pf3D7_13_v3-156713-156986-1A"   
## [71] "Pf3D7_13_v3-1725379-1725652-2"   "Pf3D7_13_v3-1725464-1725719-1B" 
## [73] "Pf3D7_13_v3-1725887-1726123-2"   "Pf3D7_13_v3-1876391-1876664-1A" 
## [75] "Pf3D7_13_v3-2114829-2115090-1A"  "Pf3D7_13_v3-2504481-2504734-1B" 
## [77] "Pf3D7_13_v3-2770591-2770863-2"   "Pf3D7_13_v3-2770621-2770854-1B" 
## [79] "Pf3D7_13_v3-2840447-2840746-2"   "Pf3D7_13_v3-2840462-2840736-1B" 
## [81] "Pf3D7_13_v3-2841390-2841688-1B2" "Pf3D7_13_v3-2844334-2844629-1B2"
## [83] "Pf3D7_13_v3-748254-748510-1B"    "Pf3D7_13_v3-935613-935884-1A"   
## [85] "Pf3D7_13_v3-958247-958510-1B"    "Pf3D7_14_v3-1038300-1038538-1A" 
## [87] "Pf3D7_14_v3-1166107-1166371-1A"  "Pf3D7_14_v3-120101-120365-1A"   
## [89] "Pf3D7_14_v3-1392837-1393086-1A"  "Pf3D7_14_v3-1956056-1956330-1B" 
## [91] "Pf3D7_14_v3-2020604-2020849-1A"  "Pf3D7_14_v3-2481033-2481276-1B" 
## [93] "Pf3D7_14_v3-2695837-2696082-1A"  "Pf3D7_14_v3-921176-921432-1A"   
## [95] "PvP01_12_v1-1184983-1185208-1AB"
## # A tibble: 273 × 2
##    locus                        length_type
##    <chr>                              <int>
##  1 Pf3D7_01_v3-162867-163115-1A         208
##  2 Pf3D7_01_v3-162867-163115-1A         202
##  3 Pf3D7_01_v3-162867-163115-1A         211
##  4 Pf3D7_01_v3-162867-163115-1A         209
##  5 Pf3D7_01_v3-162867-163115-1A         205
##  6 Pf3D7_01_v3-194742-194973-1B         177
##  7 Pf3D7_01_v3-194742-194973-1B         186
##  8 Pf3D7_01_v3-194742-194973-1B         195
##  9 Pf3D7_01_v3-194742-194973-1B         183
## 10 Pf3D7_01_v3-455794-456054-1A         193
## # ℹ 263 more rows

Look at how each individual pool amplified

Pool 1A

## [1] "No reads in any samples for these loci, for 1A/1AB"
## # A tibble: 1 × 3
##   locus                        pool      n
##   <chr>                        <chr> <dbl>
## 1 PKNH_12_v2-198869-199113-1AB 1AB      NA
## [1] "List of samples that do not have >75% loci with >100 reads, in pool 1A"
## # A tibble: 173 × 7
## # Groups:   sampleID [173]
##    sampleID                              pool  totreads   n50  n100 neg     norm
##    <chr>                                 <chr>    <int> <int> <int> <lgl>  <dbl>
##  1 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1A         235     0     0 FALSE 0     
##  2 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1A        1989     4     0 FALSE 0     
##  3 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1A        8057    61    18 FALSE 0.107 
##  4 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1A         464     0     0 FALSE 0     
##  5 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1A         989     0     0 FALSE 0     
##  6 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1A        2786     7     0 FALSE 0     
##  7 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1A        4984    28     6 FALSE 0.0357
##  8 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1A        7523    63    16 FALSE 0.0952
##  9 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1A        9277    77    23 FALSE 0.137 
## 10 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1A         698     0     0 FALSE 0     
## # ℹ 163 more rows

Pool 5

## 
## TRUE 
##   47

## [1] "Loci without any reads, pool 5"
## # A tibble: 5 × 16
##   `locus-pool`   Category chr_malaria ampInsert_start ampInsert_end GeneID Gene 
##   <chr>          <chr>    <chr>                 <dbl>         <dbl> <chr>  <chr>
## 1 Pf3D7_13_v3-2… Diagnos… Pf3D7_13_v3         2841411       2841661 PF3D7… HRP3 
## 2 Pf3D7_13_v3-2… Diagnos… Pf3D7_13_v3         2844355       2844599 <NA>   <NA> 
## 3 PmUG01_12_v1-… Species  PmUG01_12_…         1398021       1398213 PMUG0… ldh  
## 4 PocGH01_12_v1… Species  PocGH01_12…         1106483       1106671 POCGH… ldh  
## 5 PvP01_12_v1-1… Species  PvP01_12_v1         1185008       1185184 PVP01… ldh  
## # ℹ 9 more variables:
## #   `Reason_to_include_(if_drug_resistance:_aminoacids)` <chr>,
## #   `Amino_acid_range_(*:_partial_coverage_of_that_aminoacid)` <chr>,
## #   pool5 <lgl>, amplicon_id <chr>, amplicon_start <dbl>, amplicon_end <dbl>,
## #   fwd_primer <chr>, rev_primer <chr>, n <dbl>
## [1] "List of samples that do not have >75% alleles with >100 reads, pool 5"
## # A tibble: 166 × 7
## # Groups:   sampleID [166]
##    sampleID                              pool  totreads   n50  n100 neg     norm
##    <chr>                                 <chr>    <int> <int> <int> <lgl>  <dbl>
##  1 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1B          84     0     0 FALSE 0     
##  2 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1B         645     2     0 FALSE 0     
##  3 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1B        3200    22    10 FALSE 0.213 
##  4 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1B         137     0     0 FALSE 0     
##  5 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1B         349     0     0 FALSE 0     
##  6 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1B         858     2     0 FALSE 0     
##  7 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1B        1548    14     3 FALSE 0.0638
##  8 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1B        2037    18     5 FALSE 0.106 
##  9 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1B        3287    24    15 FALSE 0.319 
## 10 Gambia_Indie-1B_MH_1_AE_2023_03_06_8… 1B         266     0     0 FALSE 0     
## # ℹ 156 more rows

Pool 2

## Rows: 31 Columns: 14
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr (10): locus-pool, Category, chr_malaria, GeneID, Gene, Reason to include...
## dbl  (4): ampInsert_start, ampInsert_end, amplicon_start, amplicon_end
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Create list of samples that fail any of the QC checks by pool

Reprep if <50% amplicons with >100 reads

Repool if >50% but <75% amplicons with >100 reads

bind_tog <- bind_rows(bad_1A, bad_5) %>% 
  filter(!grepl("Neg", sampleID)) %>% 
  filter(!grepl("Pos", sampleID))
table(bind_tog$sampleID)
## 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068185300_PR1A5_S298 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068185323_PR1A5_S218 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068185326_PR1A5_S242 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068185343_PR1A5_S264 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068185391_PR1A5_S214 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068185401_PR1A5_S216 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068185567_PR1A5_S229 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068185722_PR1A5_S250 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068185876_PR1A5_S288 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068185891_PR1A5_S276 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068185903_PR1A5_S262 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068185939_PR1A5_S274 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068186019_PR1A5_S228 
##                                                        1 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068186025_PR1A5_S286 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068186063_PR1A5_S300 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068186076_PR1A5_S287 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068186110_PR1A5_S240 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068186138_PR1A5_S263 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068186207_PR1A5_S241 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068279974_PR1A5_S306 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068279988_PR1A5_S293 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068279991_PR1A5_S304 
##                                                        1 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068279996_PR1A5_S255 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280016_PR1A5_S283 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280025_PR1A5_S284 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280046_PR1A5_S261 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280050_PR1A5_S224 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280052_PR1A5_S248 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280058_PR1A5_S303 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280081_PR1A5_S268 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280088_PR1A5_S285 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280106_PR1A5_S221 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280170_PR1A5_S270 
##                                                        1 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280181_PR1A5_S295 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280188_PR1A5_S249 
##                                                        1 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280201_PR1A5_S256 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280279_PR1A5_S222 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280282_PR1A5_S236 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280290_PR1A5_S257 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280303_PR1A5_S246 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280304_PR1A5_S282 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280374_PR1A5_S266 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280398_PR1A5_S272 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280432_PR1A5_S260 
##                                                        2 
## Gambia_Indie-1B_MH_1_AE_2023_03_06_8068280471_PR1A5_S225 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068279954_PR1A5_S391 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068279957_PR1A5_S370 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068279962_PR1A5_S369 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068279967_PR1A5_S380 
##                                                        1 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068279976_PR1A5_S356 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068279983_PR1A5_S335 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068279990_PR1A5_S314 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068279999_PR1A5_S403 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280004_PR1A5_S316 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280029_PR1A5_S317 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280043_PR1A5_S333 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280059_PR1A5_S321 
##                                                        1 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280060_PR1A5_S373 
##                                                        1 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280071_PR1A5_S358 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280080_PR1A5_S357 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280095_PR1A5_S332 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280117_PR1A5_S319 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280118_PR1A5_S382 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280144_PR1A5_S381 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280165_PR1A5_S343 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280195_PR1A5_S334 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280206_PR1A5_S350 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280213_PR1A5_S325 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280215_PR1A5_S384 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280218_PR1A5_S328 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280219_PR1A5_S383 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280224_PR1A5_S389 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280236_PR1A5_S312 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280243_PR1A5_S346 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280250_PR1A5_S401 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280252_PR1A5_S385 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280286_PR1A5_S344 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280296_PR1A5_S387 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280300_PR1A5_S348 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280312_PR1A5_S378 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280323_PR1A5_S386 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280325_PR1A5_S364 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280326_PR1A5_S400 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280411_PR1A5_S371 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280421_PR1A5_S374 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280430_PR1A5_S322 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280506_PR1A5_S399 
##                                                        2 
## Gambia_Indie-1B_MH_2_AE_2023_03_28_8068280520_PR1A5_S331 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068279968_PR1A5_S449 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068279985_PR1A5_S441 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068279995_PR1A5_S429 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280003_PR1A5_S423 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280006_PR1A5_S434 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280007_PR1A5_S448 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280020_PR1A5_S499 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280045_PR1A5_S463 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280048_PR1A5_S442 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280074_PR1A5_S457 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280083_PR1A5_S415 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280090_PR1A5_S409 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280101_PR1A5_S446 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280104_PR1A5_S484 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280116_PR1A5_S435 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280124_PR1A5_S420 
##                                                        1 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280151_PR1A5_S493 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280159_PR1A5_S440 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280162_PR1A5_S410 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280164_PR1A5_S436 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280177_PR1A5_S462 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280184_PR1A5_S491 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280196_PR1A5_S458 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280203_PR1A5_S445 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280207_PR1A5_S468 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280231_PR1A5_S470 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280235_PR1A5_S424 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280239_PR1A5_S406 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280276_PR1A5_S492 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280283_PR1A5_S454 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280288_PR1A5_S456 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280298_PR1A5_S482 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280310_PR1A5_S426 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280315_PR1A5_S466 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280316_PR1A5_S479 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280320_PR1A5_S464 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280334_PR1A5_S467 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280346_PR1A5_S485 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280349_PR1A5_S407 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280351_PR1A5_S425 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280375_PR1A5_S418 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280393_PR1A5_S495 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280394_PR1A5_S431 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280396_PR1A5_S408 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280406_PR1A5_S497 
##                                                        1 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280409_PR1A5_S472 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280414_PR1A5_S432 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280429_PR1A5_S413 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280460_PR1A5_S444 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280469_PR1A5_S428 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280481_PR1A5_S476 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280485_PR1A5_S412 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280505_PR1A5_S447 
##                                                        2 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280516_PR1A5_S461 
##                                                        1 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280519_PR1A5_S460 
##                                                        1 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280591_PR1A5_S414 
##                                                        1 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280608_PR1A5_S465 
##                                                        1 
## Gambia_Indie-1B_MH_3_AE_2023_03_30_8068280683_PR1A5_S477 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068279948_PR1A5_S518 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068279953_PR1A5_S516 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068279965_PR1A5_S545 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068279981_PR1A5_S558 
##                                                        1 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068279993_PR1A5_S550 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280023_PR1A5_S551 
##                                                        1 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280027_PR1A5_S534 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280057_PR1A5_S541 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280126_PR1A5_S503 
##                                                        1 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280130_PR1A5_S528 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280134_PR1A5_S539 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280160_PR1A5_S519 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280211_PR1A5_S513 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280220_PR1A5_S530 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280225_PR1A5_S535 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280227_PR1A5_S557 
##                                                        1 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280237_PR1A5_S560 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280244_PR1A5_S548 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280292_PR1A5_S559 
##                                                        1 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280416_PR1A5_S537 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280419_PR1A5_S549 
##                                                        1 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280427_PR1A5_S556 
##                                                        1 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280440_PR1A5_S561 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280511_PR1A5_S538 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280512_PR1A5_S544 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280632_PR1A5_S527 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280637_PR1A5_S529 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280659_PR1A5_S536 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280666_PR1A5_S555 
##                                                        1 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280680_PR1A5_S552 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280685_PR1A5_S526 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280697_PR1A5_S531 
##                                                        2 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280711_PR1A5_S508 
##                                                        1 
## Gambia_Indie-1B_MH_4_AE_2023_04_05_8068280715_PR1A5_S543 
##                                                        2
# samples that need to be re-prepped
re_prep_or_re_seq <- bind_rows(bad_1A_reprep, bad_1A_repool, bad_5_reprep, bad_5_repool)
re_prep_or_re_seq <- re_prep_or_re_seq %>% 
  filter(!grepl("Neg", sampleID)) %>% 
  filter(!grepl("control", sampleID)) %>% 
  filter(!grepl("Control", sampleID))

wider <- re_prep_or_re_seq %>% 
  select(sampleID, pool, reprep, repool) %>%
  pivot_wider(id_cols = sampleID, names_from = pool, values_from = c(reprep, repool))
# replace NAs (which mean that the samples had enough reads in that pool) with 0s
wider[is.na(wider)] <- 0
# now you need to deal with collapsing by sample -- if any need to be reprepped, then all need to be reprepped
re_prep <- wider %>% 
  filter(reprep_1A == 1 | reprep_1B == 1) %>%
  select(sampleID) %>% 
  mutate(reprep = 1, repool = 0)
re_pool <- wider %>% 
  anti_join(re_prep) %>% 
  select(sampleID) %>% 
  mutate(reprep = 0, repool = 1)
## Joining with `by = join_by(sampleID)`
write.csv(re_prep, "gambia_failedQC_reprep.csv", row.names = FALSE)
write.csv(re_pool, "gambia_failedQC_repool.csv", row.names = FALSE)

Filtering

Remove bad samples

Remove bad loci

Remove controls

## [1] "Sample size= 145"
## [1] "# of entries excluded = 0, Prop. excluded = 0"
## [1] "# of loci after cleanup = 242"
## character(0)

Moire run

Set up moire input

# Use allele_data (sample filtered, but no locus/allele filtered) as moire input
moire_input <- data_filt %>% 
  select (sampleID, locus, allele) %>% 
  rename("sample_id" = "sampleID") %>% 
  distinct()
write.csv(moire_input, "gambia_moire_input.csv", row.names = F)

Extra

rough MOI estimates (No. alleles per locus/ sample)

## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

## `summarise()` has grouped output by 'locus'. You can override using the
## `.groups` argument.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.